/**
 * @BelongsProject : LeetCode
 * @Author : WXY
 * @CreateTime : 2022-12-04  21:27
 * @Description : 35. 搜索插入位置
 * @Version : 1.0
 */

public class Num035_ {
    public int searchInsert(int[] nums, int target) {
        int L = 0;
        int R = nums.length -1 ;
        int mid = 0;
        while (L <= R) {
            mid = L + (R - L) / 2;
            if (nums[mid] == target) {
                return mid;
            } else if (nums[mid] < target) {
                L = mid + 1;
            }else {
                R  = mid - 1;
            }
        }
        return L;
    }

    public static void main(String[] args) {

    }
}
